package com.admin.service;

import com.admin.bean.Tag;
import com.admin.dbdao.TagAdminDao;
import com.data.util.CheckDataUtils;
import com.data.util.DatabaseIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TagAdminService {
    @Autowired
    private TagAdminDao tagAdminDao;

    public List<Tag> listTagService() {
        return tagAdminDao.listTagDao();
    }

    public boolean addTagService(Tag tag) {
        tag.setDate(new Date());
        tag.setId(DatabaseIdUtils.getDataIdOne());
        tag.setState(false);
        return tagAdminDao.saveMassageDao(tag);
    }

    public boolean deleteTagService(String id) {
        return CheckDataUtils.stringUtilsID(id) && tagAdminDao.deleteTagDao(id);
    }
}
